
<template>
  <div v-show="visible" class="loading-wrap" :class="[type+'-wrap']">

    <div v-if="type==='ball-turn'" class="loader" :class="[type]"></div>

    <div v-if="type==='circle-dot'" class="circle-dot">
      <div class="loader"></div>
      <h2><span>加载中</span></h2>
    </div>

    <div v-if="type==='chrome-diamond-updown' || type==='chrome-circle-turn'" class="chrome" :class="[type]">
      <div class="shape shape1"></div>
      <div class="shape shape2"></div>
      <div class="shape shape3"></div>
      <div class="shape shape4"></div>
    </div>


  </div>
</template>

<script>
export default {
  data () {
    return {
      type:'circle',
      visible: false
    }
  }
}
</script>
<style lang="scss" scoped>
.loading-wrap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  &.ball-turn-wrap{
    background: #080915;
  }
  &.circle-dot-wrap{
    background: #0b0b14;
  }
  &.chrome-diamond-updown-wrap,&.chrome-circle-turn-wrap{
    background: rgba(255,255,255,.85);
  }
}


/*ball-turn*/
.ball-turn { 
  position: relative; 
  width: 60px; 
  height: 60px; 
  border-radius: 50%; 
  margin: 75px; 
  display: inline-block; 
  vertical-align: middle; 
  &.loader{
    border: 7px double #ff5722; 
    animation: ball-turn 1s linear infinite;
    &:before,&:after{
      content: ""; 
      position: absolute; 
      width: 12px; 
      height: 12px; 
      background: #ff5722; 
      border-radius: 50%; 
      bottom: 0; 
      right: 37px;
    }; 
    &:after{
      left: 37px; top: 0;
    }
  }
}

@keyframes ball-turn {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.circle-dot{
  .loader{
    position: absolute;
    margin: auto;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border-top: 2px solid #ffea29;
    border-left: 1px solid transparent;
    border-right: 1px solid transparent;
    animation: circle-dot-rt 2s infinite linear;
    &:before,&:after{
      content: "";
      position: absolute;
      margin: auto;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      border-radius: 50%;
    }
    &:before{
      width: 70px;
      height: 70px;
      border-top: 2px solid #8d29ff;
      border-left: 1px solid transparent;
      border-right: 1px solid transparent;
      animation: circle-dot-rt 4s infinite linear reverse;
    }
    &:after{
      width: 0;
      height: 0;
      border-top: initial;
      border-left: initial;
      border-right: initial;
      animation: circle-dot-cw 1s infinite;
      background: snow;
    }
  }
  h2{
    position: absolute;
    height: 40px;
    margin: auto;
    top: 200px;
    left: 0;
    right: 0;
    bottom: 0;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.1em;
    font-size: 14px;
    font-weight: lighter;
    color: white;
    &:after {
      animation: circle-dot-txt 5s infinite;
      content: "";
    };
    span {
      display: none;
    }
  }
}

@keyframes circle-dot-rt {
  100% {
    transform: rotate(360deg);
  }
}
@keyframes circle-dot-cw {
  0% {
    width: 0;
    height: 0;
  }
  75% {
    width: 40px;
    height: 40px;
  }
  100% {
    width: 0;
    height: 0;
  }
}
@keyframes circle-dot-txt {
  0% {
    content: "加载中.";
  }
  50% {
    content: "加载中..";
  }
  100% {
    content: "加载中...";
  }
}


/*谷歌加载*/
.chrome{
  width: 30px;
  height: 30px;
  position: relative;
  .shape{
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 1px;
  }
  .shape1{
    left: 0;
    background-color: #5C6BC0;
  }
  .shape2{
    right: 0;
    background-color: #8BC34A;
  }
  .shape3{
    bottom: 0;
    background-color: #FFB74D;
  }
  .shape4{
    bottom: 0;
    right: 0;
    background-color: #F44336;
  }
  &-diamond-updown{
    transform: rotate(45deg);
    .shape1 {
      animation: chrome-diamond-updown-shape1 0.5s ease 0s infinite alternate;
    }
    .shape2 {
      animation: chrome-diamond-updown-shape2 0.5s ease 0s infinite alternate;
    }
    .shape3 {
      animation: chrome-diamond-updown-shape3 0.5s ease 0s infinite alternate;
    }
    .shape4 {
      animation: chrome-diamond-updown-shape4 0.5s ease 0s infinite alternate;
    }
  }
  &-circle-turn{
    transform: rotate(10deg);
    animation: rotation 1s infinite;
    .shape{
      border-radius: 50%;
    }
    .shape1 {
      animation: chrome-circle-turn-shape1 0.5s ease 0s infinite alternate;
    }
    .shape2 {
      animation: chrome-circle-turn-shape2 0.5s ease 0s infinite alternate;
    }
    .shape3 {
      animation: chrome-circle-turn-shape3 0.5s ease 0s infinite alternate;
    }
    .shape4 {
      animation: chrome-circle-turn-shape4 0.5s ease 0s infinite alternate;
    }
  }
}

@keyframes chrome-diamond-updown-shape1 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(16px, 16px);
  }
}

@keyframes chrome-diamond-updown-shape2 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(-16px, 16px);
  }
}

@keyframes chrome-diamond-updown-shape3 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(16px, -16px);
  }
}

@keyframes chrome-diamond-updown-shape4 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(-16px, -16px);
  }
}

@keyframes chrome-circle-turn-shape1 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(20px, 20px);
  }
}

@keyframes chrome-circle-turn-shape2 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(-20px, 20px);
  }
}

@keyframes chrome-circle-turn-shape3 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(20px, -20px);
  }
}

@keyframes chrome-circle-turn-shape4 {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(-20px, -20px);
  }
}

@keyframes rotation {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style>
